#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

string s;
int k;
char a, b;
vector<int> ai, bi;

int main()
{
    ai.push_back(0), bi.push_back(0);
    cin >> k >> s >> a >> b;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == a) ai.push_back(i);
        if(s[i] == b) bi.push_back(i);
    }
    // 可以保证ai数组和bi数组一定是有序的，所以可以用二分
    long long ans = 0;
    for(auto e: bi)
    {
        int target = e - k + 1;
        // 二分查找小于或者等于target的下标
        int l = 0, r = ai.size() - 1;
        while(l < r)
        {
            int mid = l + r + 1 >> 1;
            if(ai[mid] > target)
                r = mid - 1;
            else 
                l = mid;
        }
        ans += l;
    }
    cout << ans << endl;
}